package cn.ekuma.android.driver.display;

import android_serialport_api.SerialPort;

import com.openbravo.pos.config.ParametersConfig;
import com.openbravo.pos.display.OEMDISPLAY_8BIT;
import com.openbravo.pos.printer.escpos.PrinterWritter;
import com.openbravo.pos.util.PrinterUtil;

import cn.ekuma.android.driver.DeviceDisplay;
import cn.ekuma.android.driver.PrinterWritterCom;
import cn.ekuma.android.driver.com.DeviceDisplayCom;

public  class AbstractDeviceDisplayChinaOEM implements DeviceDisplay {

	protected PrinterWritter display;  
	
	
	public String getDisplayType() {
		return "ChinaOEM";
	}

	public void repaintLines() {
		
	}

	@Override
	public void writeVisor(int animation, String sLine1, String sLine2) {
		writeVisor(sLine1,sLine2);
	}

	@Override
	public void writeVisor(String sLine1, String sLine2) {
		display.write(OEMDISPLAY_8BIT.VISOR_CLEAR);
		display.write(OEMDISPLAY_8BIT.VISOR_CAN);
		String ledStr=sLine2.trim();
		if(ledStr!=null&&!ledStr.isEmpty())
			if(OEMDISPLAY_8BIT.VISOR_SHOW_PRICE_STR.equalsIgnoreCase(ledStr))
				display.write(OEMDISPLAY_8BIT.VISOR_SHOW_PRICE);
			else if(OEMDISPLAY_8BIT.VISOR_SHOW_TOTAL_STR.equalsIgnoreCase(ledStr))
				display.write(OEMDISPLAY_8BIT.VISOR_SHOW_TOTAL);
			else if(OEMDISPLAY_8BIT.VISOR_SHOW_TAKEING_STR.equalsIgnoreCase(ledStr))
				display.write(OEMDISPLAY_8BIT.VISOR_SHOW_TAKEING);
			else if(OEMDISPLAY_8BIT.VISOR_SHOW_CHANGE_STR.equalsIgnoreCase(ledStr))
				display.write(OEMDISPLAY_8BIT.VISOR_SHOW_CHANGE);
		Double price=Double.valueOf(sLine1.trim());
		display.write(PrinterUtil.alignRight(String.valueOf(price), 8));
		//display.flush();
	}

	public void initVisor() {
		display.init(OEMDISPLAY_8BIT.INIT);
		display.write(OEMDISPLAY_8BIT.VISOR_CLEAR);
		//display.flush();
	}

	
	public void clearVisor() {
		display.write(OEMDISPLAY_8BIT.VISOR_CLEAR);
		//display.flush();
	}


	@Override
	public String getDisplayName() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public String getDisplayDescription() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public ParametersConfig getConfiguration() {
		// TODO Auto-generated method stub
		return null;
	}

}
